#!/bin/bash
if [ -n "$1" ] ; then
  data_str=$1
else
  data_str=`date -d "-1 days" +%F`
fi

SQL_DWD_EVENT_LOG_DETAIL="
INSERT OVERWRITE TABLE jtp_app_dwd.dwd_event_log_detail PARTITION (dt = '${data_str}')
SELECT account
,appid
,appversion
,carrier
,deviceid
,devicetype
,eventid
,ip
,CAST(latitude AS DOUBLE) AS latitude
,CAST(longitude AS DOUBLE) AS longitude
,province
,city
,district
,nettype
,osname
,osversion
,properties
,releasechannel
,resolution
,new_sessionid
,CAST(\`timestamp\` AS BIGINT) AS event_ts
FROM jtp_app_tmp.tmp_event_log_area  WHERE dt='${data_str}';
"

/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e "${SQL_DWD_EVENT_LOG_DETAIL}"
